import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'index',
    redirect: '/main'
  },
  {
    path: '/login',
    name: 'login',
    component:  () => import('../views/Login.vue'),
  },
  {
    path: '/main',
    name: 'main',
    component: () => import('../views/Main.vue'),
    redirect: '/main/home',
    children: [
      {
        path: '/main/home',
        name: 'home',
        component: () => import('../views/HomeView.vue'),
      },
      {
        path: '/main/search',
        name: 'search',
        component: () => import('../views/SearchView.vue'),
      },
      {
        path: '/main/order',
        name: 'order',
        component: () => import('../views/OrderView.vue'),
      },
      {
        path: '/main/user',
        name: 'user',
        component: () => import('../views/UserView.vue'),
      },
      {
        path: '/main/food/:bid',
        name: 'food',
        component: () => import('../views/FoodView.vue'),
      },
      {
        path: '/main/address',
        name: 'address',
        component: () => import('../views/AddressView.vue'),
      },
      {
        path: '/main/addAddress',
        name: 'addAddress',
        component: () => import('../views/AddAddressView.vue'),
      },
      {
        path: '/main/orderDetail/:orderId',
        name: 'orderDetail',
        component: () => import('../views/OrderDetailView.vue'),
      },
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router